"""
aula7
hash table
soraia janeiro
"""

# -*- coding: utf-8 -*-
import math

class hashTable():
	def __init__(self):
		self.m = m
		self.n = n
		self.T = [[] for k in range(m)]

	def hashMult(self, k):
		A = (math.sqrt(5.0) - 1) / 2.0
		return int(math.floor(self.m * (k*A % 1)))
	
	def hashInsert(self, k):
		self.T[self.hashMult(k)].append(k)
		pass
	
	def hashSearch(self, k):
		h = self.hashMult(k)
		x = self.T[h].index(k)
		print x
		res = ""
		res += '---\nh = '
		res += str(h)
		res += ' x = '
		res += str(x)
		return res
		
	def __str__(self):
		s = ""
		x = 0
		for k in range (1, len(self.T)):
			s += "\n Lista = " + str(self.T[k])
			s += str(1)	
			x += 1
		return s


m = 5
n = 10
ht = hashTable()
for k in range (0, 34):
	ht.hashInsert(k)
	pass
print "After"
print ht
res = ht.hashSearch(10)
print res

	
